package com.itheima.homework.test5;

import java.util.ArrayList;
import java.util.Iterator;

/*
为方便管理，现需要将班级中学员的信息（学号、姓名、年龄）存储起来。请使用所学集合知识将信息遍历打印。
请使用foreach语句完成集合的遍历，效果如下：
姓名：吕布，学号：001，年龄：18
姓名：赵云，学号：002，年龄：19
姓名：典韦，学号：003，年龄：20
...
 */
public class Demo5 {
    public static void main(String[] args) {
        ArrayList<Student> list = new ArrayList<>();
        Student stu1 = new Student("001","吕布",18);
        Student stu2 = new Student("002","赵云",19);
        Student stu3 = new Student("003","典韦",20);
        list.add(stu1);
        list.add(stu2);
        list.add(stu3);
        Iterator<Student> it = list.iterator();
        while (it.hasNext()){
            Student s = it.next();
            System.out.println(s);
        }
        System.out.println("...");

    }
}
class Student{
    private String id;
    private String name;
    private int age;

    public Student() {
    }

    public Student(String id, String name, int age) {
        this.id = id;
        this.name = name;
        this.age = age;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "姓名："+name+"，学号："+id+"，年龄："+age;
    }
}